﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportToPLMX.CCoExportToPLMXUtils
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using DnProcessSimulateCommands.ExportToPLMX.Resources;
using Microsoft.Win32;
using System.Resources;
using System.Windows.Forms;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.ExportToPLMX;

public class CCoExportToPLMXUtils
{
  private static readonly string REGISTRY_PATH = TxApplication.RegistryPath + "\\TUNE\\NewAssembler\\PLMX";

  internal static void SaveValueToRegistry(string key, string value)
  {
    RegistryKey registryKey;
    using (registryKey = Registry.CurrentUser.OpenSubKey(CCoExportToPLMXUtils.REGISTRY_PATH, true))
    {
      if (registryKey == null)
        registryKey = Registry.CurrentUser.CreateSubKey(CCoExportToPLMXUtils.REGISTRY_PATH);
      registryKey.SetValue(key, (object) value);
    }
  }

  internal static string ReadValueFromRegistry(string key)
  {
    string str = (string) null;
    RegistryKey registryKey1 = Registry.CurrentUser.OpenSubKey(CCoExportToPLMXUtils.REGISTRY_PATH);
    if (registryKey1 != null)
    {
      str = registryKey1.GetValue(key) as string;
    }
    else
    {
      RegistryKey registryKey2 = Registry.LocalMachine.OpenSubKey(CCoExportToPLMXUtils.REGISTRY_PATH, true);
      if (registryKey2 != null)
        str = registryKey2.GetValue(key) as string;
    }
    return str ?? string.Empty;
  }

  public static ResourceManager GetResourceManager()
  {
    return new ResourceManager("DnProcessSimulateCommands.ExportToPLMX.Resources.CApETPXStringTable", typeof (CApETPXStringTable).Assembly);
  }

  public static void ShowErrorMessage(string msg)
  {
    int num = (int) TxMessageBox.Show(CCoExportToPLMXUtils.GetResourceManager().GetString(msg), CCoExportToPLMXUtils.GetResourceManager().GetString("ETPX_ERROR_CAPTION"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
  }
}
